<?php
/**
 * theme : default
 * template : home
 * description : accueil
 * author : Gmax
 */
$accueil = PWE::getHomePage();
if($_SERVER['REQUEST_URI']===''||$_SERVER['REQUEST_URI']==='/'){
    header('location: '.$accueil->getUrl());
    ob_end_flush();
    exit;
}

if($accueil!==null){
    $slider = modele_galerie::findByPermalien('galerie_page_'.$accueil->getId(), 'galerie');
    if($slider===null && $accueil->haveMedia()){
        $topImage = $accueil->getMedia();
    }else{
        $topImage = null;
    }
}else{
    $topImage = null;
    $slider = null;
}
?>
<?php if(isset($slider)): ?>
<div id="slider-top-image">
    <ul>
    <?php foreach($slider->getMedias() as $num=>$media): ?>
        <li id="step-<?php echo $num; ?>">
            <div class="top-image">
                <img class="banniere" src="<?php echo $media->getUrl(); ?>" width="<?php echo $media->getWidth(); ?>" title="<?php echo $media->getTitle(); ?>" alt="<?php echo $media->getLegende(); ?>"/>
            </div>
        </li>
    <?php endforeach; ?>
    </ul>
</div>
<?php elseif(isset($topImage)&&$topImage!==null&&$topImage->getHeight()>0): ?>
<div class="top-image">
    <img class="banniere" src="<?php echo $topImage->getUrl(); ?>" width="<?php echo $topImage->getWidth(); ?>" alt="<?php echo $topImage->getLegende(); ?>" title="<?php echo $topImage->getTitle(); ?>"/>
</div>
<?php else: ?>
<div class="gabarit-top-image">
    &nbsp;
</div>
<?php endif; ?>
<div class="separateur">&nbsp;</div>
<div id="content">
    <div class="container ligne_1">
        <div class="columns four bg_vert">
            <div class="encart-sidebar text-center">
                <h4>Découvrez nos<br/>menus</h4>
                <div class="couvert" style="margin-top: 25px;margin-bottom: 20px;">&nbsp;</div>
                <p>
                    <a href="<?php echo $this->getBaseUrl(); ?>les-menus/" class="blanc">> voir la carte</a>
                </p>
            </div>
        </div>
        <div class="columns seven">
            <img src="<?php echo $this->getBaseUrl(); ?>uploads/images/home1.jpg"/>
        </div>
        <div class="columns five bg_brun">
            <div class="encart-sidebar text-center">
                <?php
                $adresse = modele::findByPermalien('adresse', 'category');
                if($adresse!==null && $adresse->getNombrePublications(true)>0){
                    $articleAdresse = $adresse->getPublications(0,1,true);
                    echo $articleAdresse[0]->getContent();
                }
                ?>
                <p><img src="<?php echo $this->getBaseUrl().$this->getThemePath().'/gfx/arabesque.png'; ?>" title="séparateur de block" alt="séparateur"/></p>
                <?php
                $horaires = modele::findByPermalien('horaires', 'category');
                if($horaires!==null && $horaires->getNombrePublications(true)>0){
                    $articleHoraires = $horaires->getPublications(0,1,true);
                    echo $articleHoraires[0]->getContent();
                }
                ?>
            </div>
        </div>
    </div>
    <div class="separateur">&nbsp;</div>
    <div class="container ligne_2">
        <div class="columns four">
            <img src="<?php echo $this->getBaseUrl(); ?>uploads/images/home2.jpg" />
        </div>
        <div class="columns seven bleu_gris">
            <article id="home"><div class="article" itemscope itemtype="http://schema.org/Article">
                <div class="post-content">
                    <h2 class="title" itemprop="name"><?php echo $accueil->getTitle(); ?></h2>
                    <?php echo $accueil->getContent(); ?>
                </div>
            </div></article></div>
        <div class="columns five">
            <div class="encart-sidebar text-center">
                <h4 class="vert">Découvrez notre<br/>carte des vins</h4>
                <div class="verre" style="margin-top: 2px;margin-bottom: 8px;">&nbsp;</div>
                <p>
                    <a href="<?php echo $this->getBaseUrl(); ?>les-vins/" class="vert">> voir la carte</a>
                </p>
            </div>
        </div>
    </div>
</div>